<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Mac 终极终端配置, 湮灭星空,博客,Python,后端">
    <meta name="description" content="MAC 终极终端配置
安装 iTerm2
官网地址下载安装：https://iterm2.com/downloads.html
安装 oh-my-zsh
Oh-my-zsh 官网：https://ohmyz.sh/
官网推荐的安装方式：
s">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Mac 终极终端配置 | 湮灭星空</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>

<link rel="alternate" href="/atom.xml" title="湮灭星空" type="application/atom+xml">
</head>

<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper head-container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">湮灭星空</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友链</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">湮灭星空</div>
        <div class="logo-desc">
            
            天下寥寥，苍生涂涂，诸子百家，唯我纵横
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友链
		</a>
          
        </li>
        
        
    </ul>
</div>

        </div>

        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/14.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        Mac 终极终端配置
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/oh-my-zsh/">
                                <span class="chip bg-color">oh-my-zsh</span>
                            </a>
                        
                            <a href="/tags/mac/">
                                <span class="chip bg-color">mac</span>
                            </a>
                        
                            <a href="/tags/brew/">
                                <span class="chip bg-color">brew</span>
                            </a>
                        
                            <a href="/tags/Terminal/">
                                <span class="chip bg-color">Terminal</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/Tech/" class="post-category">
                                Tech
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2019-11-27
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2019-11-29
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    2.1k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    8 分
                </div>
                
				
                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
            
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="mac-终极终端配置"><a class="header-anchor" href="#mac-终极终端配置"></a>MAC 终极终端配置</h1>
<h2 id="安装-iterm2"><a class="header-anchor" href="#安装-iterm2"></a>安装 iTerm2</h2>
<p>官网地址下载安装：<a href="https://iterm2.com/downloads.html" target="_blank" rel="noopener">https://iterm2.com/downloads.html</a></p>
<h2 id="安装-oh-my-zsh"><a class="header-anchor" href="#安装-oh-my-zsh"></a>安装 oh-my-zsh</h2>
<p>Oh-my-zsh 官网：<a href="https://ohmyz.sh/" target="_blank" rel="noopener">https://ohmyz.sh/</a></p>
<p>官网推荐的安装方式：</p>
<pre><code class="language-shell">sh -c &quot;$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)&quot;
</code></pre>
<h3 id="使用技巧"><a class="header-anchor" href="#使用技巧"></a>使用技巧</h3>
<p>目录浏览和跳转：输入 d，即可列出你在这个会话里访问的目录列表，输入列表前的序号，即可直接跳转。</p>
<h2 id="安装-homebrew"><a class="header-anchor" href="#安装-homebrew"></a>安装 Homebrew</h2>
<p>Homebrew 官网：<a href="https://brew.sh/index_zh-cn" target="_blank" rel="noopener">https://brew.sh/index_zh-cn</a>，安装：</p>
<pre><code class="language-shell">/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;
</code></pre>
<p>安装 <code>brew cask</code>，使用 <code>brew cask</code> 安装 macOS 应用程序、字体和插件以及其他非开源软件。</p>
<pre><code class="language-shell">brew cask	# 第一次会安装 brew cask
brew cask install firefox # 实例
</code></pre>
<h3 id="brew-换清华源"><a class="header-anchor" href="#brew-换清华源"></a>brew 换清华源</h3>
<p>清华镜像站点 Homebrew 镜像使用帮助地址：<a href="https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/" target="_blank" rel="noopener">https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/</a></p>
<pre><code class="language-shell">git -C &quot;$(brew --repo)&quot; remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

git -C &quot;$(brew --repo homebrew/core)&quot; remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

git -C &quot;$(brew --repo homebrew/cask)&quot; remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

brew update
</code></pre>
<h3 id="brew-回复官方源"><a class="header-anchor" href="#brew-回复官方源"></a>brew 回复官方源</h3>
<pre><code class="language-shell">git -C &quot;$(brew --repo)&quot; remote set-url origin https://github.com/Homebrew/brew.git

git -C &quot;$(brew --repo homebrew/core)&quot; remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C &quot;$(brew --repo homebrew/cask)&quot; remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update
</code></pre>
<h2 id="brew-插件"><a class="header-anchor" href="#brew-插件"></a>brew 插件</h2>
<p><a href="https://juejin.im/post/5c3dcecef265da6163024b1c?utm_medium=fe&amp;utm_source=weixinqun#heading-10" target="_blank" rel="noopener">优秀的命令行工具整理 （一）</a></p>
<p><a href="https://juejin.im/post/5c418e2df265da616501d461#heading-8" target="_blank" rel="noopener">优秀的命令行工具整理（二）</a></p>
<h3 id="autojump-自动跳转目录"><a class="header-anchor" href="#autojump-自动跳转目录"></a>autojump 自动跳转目录</h3>
<p>安装后添加到 <code>autojump</code> 到 <code>zsh</code> 的 插件配置（~/.zshrc 文件的 plugins）里，再追加一句命令：</p>
<pre><code class="language-shell">brew install autojump
sudo vi ~/.zshrc
echo '# 激活autojump' &gt;&gt; ~/.zshrc
echo '[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] &amp;&amp; . $(brew --prefix)/etc/profile.d/autojump.sh' &gt;&gt; ~/.zshrc
source ~/.zshrc
</code></pre>
<h3 id="bat-文件高亮输出"><a class="header-anchor" href="#bat-文件高亮输出"></a>bat 文件高亮输出</h3>
<p><code>bat</code> 代替 <code>cat</code>，<code>cat</code> 某个文件，可以在终端直接输出文件内容，<code>bat</code> 相比 <code>cat</code> 增加了行号和颜色高亮 👍</p>
<pre><code class="language-shell">brew install bat
</code></pre>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-168516fbb188b916.svg" alt=""></p>
<h3 id="fd-搜索文件"><a class="header-anchor" href="#fd-搜索文件"></a>fd 搜索文件</h3>
<pre><code class="language-shell">brew install fd
</code></pre>
<p>通常使用 <code>find</code> 命令基于正则表达式查找文件或目录。<a href="https://git.io/fwls2" target="_blank" rel="noopener"><code>fd</code></a> 是用 Rust 编写的 <code>find</code> 替代品。使用合理的默认值，提供更方便的界面，速度也更快。</p>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-168516fb6107ec2c.svg" alt=""></p>
<p><code>fd</code> 遵循 .gitignore 文件，也支持并行命令执行。并行命令执行可以在搜索返回的每个文件和目录上（并行）执行命令。<code>fd</code> 文档中的一个例子是找出所有 .jpg 文件，并行转换为 .png 文件（使用 <code>convert</code> 命令）：</p>
<pre><code class="language-shell">fd -e jpg -x convert {} {.}.png
</code></pre>
<h3 id="rg-搜索文件中的字符"><a class="header-anchor" href="#rg-搜索文件中的字符"></a>rg 搜索文件中的字符</h3>
<pre><code class="language-shell">brew install ripgrep
</code></pre>
<p><code>rg</code> (ripgrep) 查找文件中的字符串，<a href="https://git.io/vPvif" target="_blank" rel="noopener"><code>rg</code></a> 是 grep 的替代品，它比 <code>grep</code> 快很多。</p>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-168516fb62cd358a.svg" alt=""></p>
<p><code>rg</code> 是用 Rust 编写的，VS Code 编辑器的搜索功能其实是通过调用 rg 实现的。在性能评测中，rg 一贯超过类似工具。</p>
<h3 id="fzf-快速模糊搜索"><a class="header-anchor" href="#fzf-快速模糊搜索"></a>fzf 快速模糊搜索</h3>
<pre><code class="language-shell">brew install fzf
</code></pre>
<p><code>fzf</code> 是快速模糊搜寻。安装 <a href="https://git.io/C4FBDw" target="_blank" rel="noopener"><code>fzf</code></a> 后，在命令行的任何地方按下 <code>Ctrl + T</code>，就可以开启交互式模糊搜索界面，递归搜索当前目录下的文件。输入搜索项后，上、下键选择结果，回车上屏：<img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-168516fbb0f385c8.svg" alt=""></p>
<p>在上面的例子中，我输入了 <code>bat</code>（还可以是其他任何命令，例如 <code>less</code>、<code>cd</code> 等），接着按下 <code>Ctrl + T</code>。接着输入 <code>five</code>，回车，插入路径 <code>src/five.rs</code> 至光标所在处，而不必先输入 <code>src</code>，再按 tab 键，再输入 <code>fi</code>，再按 tab 键——路径很长或者不好记的时候，这样很麻烦。</p>
<h3 id="bench-代码性能测试工具"><a class="header-anchor" href="#bench-代码性能测试工具"></a>bench 代码性能测试工具</h3>
<pre><code class="language-shell">brew install bench
</code></pre>
<p><a href="https://git.io/fhZwU" target="_blank" rel="noopener"><code>bench</code></a> 是极为有用的测试代码性能的工具。它是用 Haskell 写的，从这点上说，算是这篇文章中最酷的。任何可以在终端中运行的命令都可以传给它（加引号），bench 会重复运行该命令，测量执行时间。测试完成后，bench 会输出有用的统计数据。</p>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-168516fb5f3d7b13-1.svg" alt=""></p>
<p>衡量代码执行时间，相比系统内置的 <code>time</code> 命令，bench 更为强大。类似的工具有 <a href="https://git.io/fhZwN" target="_blank" rel="noopener"><code>hyperfine</code></a> ，是用 Rust 编写的。</p>
<h3 id="wrk-api-测试工具"><a class="header-anchor" href="#wrk-api-测试工具"></a>wrk API 测试工具</h3>
<pre><code class="language-shell">brew install wrk
</code></pre>
<p><a href="https://github.com/wg/wrk" target="_blank" rel="noopener"><code>wrk</code></a> 是个方便的小工具，可以测试 API 性能。为了演示它的用法，我在本地的 8001 端口运行了一个最小化的 Python HTTP API 服务器，它只有一个端点（<code>/hello</code>）。用 <code>wrk</code> 测试它的性能（5 秒内，使用 12 个线程发起 200 个连接）：</p>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-168516fc5cbf22c5.svg" alt=""></p>
<p>调整线程数、连接数、时长可以测试不同负载下 API 的表现。它不能代替 Locust 和 JMeter 这样的性能测试工具，但很轻量，在许多场景下够用。</p>
<p>很不幸，基于 <code>wrk</code> 的命令行接口发起 POST 请求很笨拙：需要用 Lua 编写一个小脚本，作为参数传给命令（详见文档）。</p>
<h3 id="exa-ls-de-替代品"><a class="header-anchor" href="#exa-ls-de-替代品"></a>exa ls de 替代品</h3>
<pre><code class="language-shell">brew install exa
</code></pre>
<p><a href="https://the.exa.website/" target="_blank" rel="noopener"><code>exa</code></a> 是 <code>ls</code> 的现代替代品，其彩色输出更为易读，并提供了更多控制输出如何呈现的选项。</p>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-168516fc10cb5b64.svg" alt=""></p>
<p>加上 <code>--git-ignore</code> 参数会根据 .gitignore 忽略对应文件，使用 <code>-T</code> 参数则能以树型结构列出目录。</p>
<h3 id="asciinema-录屏"><a class="header-anchor" href="#asciinema-录屏"></a>asciinema 录屏</h3>
<pre><code class="language-shell">brew install asciinema
# 开始记录 first-rec.cast是自定义的文件名 也可以没有文件名
asciinema rec first-rec.cast
# 停止记录
exit
# 按Enter键，然后 访问出现的 url

# ctrl + c 会存到本地，asciinema upload first-rec.cast 可以再次上传到官网

# 登录
asciinema auth
# 首次注册会去官网，然后写个邮箱，邮箱会受到邮件，点击链接即注册
# 之后，一般会向邮箱里发送登录验证，点击即可
# 然后就会将你录制的视频，存在你的账号下
</code></pre>
<p>html 显示</p>
<pre><code class="language-html">&lt;a href=&quot;https://asciinema.org/a/14?autoplay=1&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/14.png&quot; width=&quot;836&quot;/&gt;&lt;/a&gt;
</code></pre>
<p>markdown 显示</p>
<pre><code class="language-markdown">[![asciicast](https://asciinema.org/a/14.png)](https://asciinema.org/a/14)
</code></pre>
<h2 id="zsh-插件"><a class="header-anchor" href="#zsh-插件"></a>zsh 插件</h2>
<p><code>zsh</code> 官方推荐插件：<a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins-Overview" target="_blank" rel="noopener">https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins-Overview</a></p>
<h3 id="extract-解压插件"><a class="header-anchor" href="#extract-解压插件"></a>extract 解压插件</h3>
<p>功能强大的解压插件，所有类型的文件解压一个命令<code>x</code>全搞定，再也不需要去记<code>tar</code>后面到底是哪几个参数了。</p>
<p><code>extract</code> 是 <code>zsh</code> 内置的插件，不需要另外克隆项目，只需要在 <code>~/.zshrc</code> 中配置一下就好了：</p>
<pre><code class="language-shell">plugins=(extract)
</code></pre>
<p>因为 <code>extract</code> 插件依赖于 <code>unrar</code>，安装：</p>
<pre><code class="language-shell">brew install unrar
</code></pre>
<h3 id="zsh-autosuggestions-zsh-syntax-highlighting"><a class="header-anchor" href="#zsh-autosuggestions-zsh-syntax-highlighting"></a>zsh-autosuggestions 、 zsh-syntax-highlighting</h3>
<p>这是一个神奇的终端自动提示插件，当你输入 ps 的时候它可能会出现 <code>ps -ef | grep helloworld</code>。是因为它会记住你曾经输入过的命令，当你再次输入前几个命令的时候帮你自动匹配，让你工作更高效。</p>
<ol>
<li>克隆项目</li>
</ol>
<pre><code class="language-shell">git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
</code></pre>
<ol start="2">
<li>
<p>配置 <code>~/.zshrc</code></p>
<pre><code class="language-shell">sudo vi ~/.zshcr
</code></pre>
<p>将 <code>zsh-autosuggestions</code> 插件激活，保存退出 <code>~/.zshrc</code></p>
<pre><code class="language-shell">plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
</code></pre>
</li>
<li>
<p>重新加载 <code>~/.zshrc</code></p>
<pre><code class="language-shell">source ~/.zshrc
</code></pre>
</li>
</ol>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-114756.png" alt="image-20191127194755828"></p>
<h2 id="oh-my-zsh-配置-powerlevel9k-主题"><a class="header-anchor" href="#oh-my-zsh-配置-powerlevel9k-主题"></a>Oh-my-zsh 配置 powerlevel9k 主题</h2>
<p>源地址：<a href="https://blog.biezhi.me/2018/11/build-a-beautiful-mac-terminal-environment.html" target="_blank" rel="noopener">https://blog.biezhi.me/2018/11/build-a-beautiful-mac-terminal-environment.html</a></p>
<p><code>zsh</code> 主题文件存储在 <code>~/.oh-my-zsh/themes</code> 目录下，</p>
<pre><code class="language-shell">cd ~/.oh-my-zsh/themes
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
</code></pre>
<p>在 <code>~/.zshrc</code> 内配置：</p>
<pre><code class="language-shell">ZSH_THEME=&quot;powerlevel9k/powerlevel9k&quot;
</code></pre>
<p>重载生效</p>
<pre><code class="language-shell">source ~/.zshrc
</code></pre>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-121835.png" alt="powerlevel9k"></p>
<blockquote>
<p>这里 iTerm2 的代码配色选择的是：<strong>Dracula</strong></p>
</blockquote>
<p><code>powerlevel9k</code> 其他配置：</p>
<pre><code class="language-shell"># powerlevel9k 配置
POWERLEVEL9K_MODE=&quot;nerdfont-complete&quot; # 设置 powerlevel9k 的字体是我们前面下载的
# Customise the Powerlevel9k prompts
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time ssh dir vcs newline) # 将前面居右的几个元素放在左边了
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() # 右边不放置任何元素（如果你喜欢在右边也可以加）
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true # 在每个提示之前添加换行符
</code></pre>
<ul>
<li><code>POWERLEVEL9K_MODE</code>：设置 powerlevel9k 的字体是我们前面下载的</li>
<li><code>POWERLEVEL9K_LEFT_PROMPT_ELEMENTS</code>：将前面居右的几个元素放在左边了</li>
<li><code>POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS</code>：右边不放置任何元素（如果你喜欢在右边也可以加）</li>
<li><code>POWERLEVEL9K_PROMPT_ADD_NEWLINE</code>：在每个提示之前添加换行符</li>
</ul>
<blockquote>
<p>关于自定义显示的详细资料：<a href="https://hant.helplib.com/GitHub/article_121915" target="_blank" rel="noopener">https://hant.helplib.com/GitHub/article_121915</a></p>
</blockquote>
<p>效果如下：</p>
<p>![image-20191127204036960](/Users/klause/Library/Application Support/typora-user-images/image-20191127204036960.png)</p>
<p>更详细的配置可以参考 <a href="https://github.com/bhilburn/powerlevel9k#prompt-customization" target="_blank" rel="noopener">Prompt Customization</a> 和 <a href="https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt" target="_blank" rel="noopener">Stylizing Your Prompt</a>。</p>
<h2 id="安装-colorls"><a class="header-anchor" href="#安装-colorls"></a>安装 colorls</h2>
<p><a href="https://github.com/athityakumar/colorls" target="_blank" rel="noopener">colors</a> 是一个 Ruby 实现的脚本，它可以配合 powerlevel9k 显示电脑上的文件图标（应该是通过后缀判断的），使用的效果如下：</p>
<p><img src="https://klause-blog-pictures.oss-cn-shanghai.aliyuncs.com/ipic/2019-11-27-122338.png" alt="colors"></p>
<p>安装</p>
<pre><code class="language-shell">sudo gem install colorls
</code></pre>

<div id="gitalk-container"></div>
<script src="https://cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script><link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css"><script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>

		<script>
		var gitalkConfig = {"clientID":"9eb5bc3ac1e1ff3ddac0","clientSecret":"4b7ae28042282281295075c2bf0c97ff1791cfeb","repo":"HexoBlogComments","owner":"Annihilater","admin":["Annihilater"],"distractionFreeMode":false};
	    gitalkConfig.id = md5(location.pathname);
		var gitalk = new Gitalk(gitalkConfig);
	    gitalk.render("gitalk-container");
	    </script>
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://www.klause.cn" rel="external nofollow noreferrer">湮灭星空</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://www.klause.cn/2019/11/27/chong-zhuang-xi-tong-pei-zhi/zhong-duan-pei-zhi/">https://www.klause.cn/2019/11/27/chong-zhuang-xi-tong-pei-zhi/zhong-duan-pei-zhi/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="https://www.klause.cn" target="_blank">湮灭星空</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/oh-my-zsh/">
                                    <span class="chip bg-color">oh-my-zsh</span>
                                </a>
                            
                                <a href="/tags/mac/">
                                    <span class="chip bg-color">mac</span>
                                </a>
                            
                                <a href="/tags/brew/">
                                    <span class="chip bg-color">brew</span>
                                </a>
                            
                                <a href="/tags/Terminal/">
                                    <span class="chip bg-color">Terminal</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
        </div>
    </div>

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2019/11/27/chong-zhuang-xi-tong-pei-zhi/chrome-shou-dong-an-zhuang.crx-cha-jian/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/18.jpg" class="responsive-img" alt="Chrome 手动安装.crx插件">
                        
                        <span class="card-title">Chrome 手动安装.crx插件</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Chrome 手动安装.crx插件
在网上自己下载.crx的离线插件文件。或者通过朋友打包.crx文件。打包方式可参照Chrome 打包扩展程序
方法一

打开Chrome浏览器，地址栏输入  chrome://extensions/
将.
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2019-11-27
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/Tech/" class="post-category">
                                    Tech
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E8%BD%AC%E8%BD%BD/">
                        <span class="chip bg-color">转载</span>
                    </a>
                    
                    <a href="/tags/chrome/">
                        <span class="chip bg-color">chrome</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2019/11/25/scrapy/crawlab-jian-dan-shi-yong-jiao-cheng/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/1.jpg" class="responsive-img" alt="Scrapy/Crawlab 简单使用教程">
                        
                        <span class="card-title">Scrapy/Crawlab 简单使用教程</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Crawlab 简单使用教程
Crawlab 是基于 Golang 的分布式爬虫官理平台，支持以及多种爬虫框架。
Crawlab 的官方文档虽然有了但是并不是很详细，作为初学者在使用的时候还是踩了一些坑，在此记录下，希望可以帮助到你。
Cr
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2019-11-25
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            湮灭星空
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>

    
<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>

    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4, h5, h6'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4, h5, h6').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">年份</span>
            <a href="https://www.klause.cn" target="_blank">湮灭星空</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">199.2k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    window.setTimeout("siteTime()", 1000);
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2019";
                    var startMonth = "6";
                    var startDate = "28";
                    var startHour = "0";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            
            <span id="icp"><img src="/medias/icp.png" style="vertical-align: text-bottom;" />
                <a href="http://www.beian.miit.gov.cn" target="_blank">皖ICP备18005729号-1</a>
            </span>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/Annihilater" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:yanmiexingkong@gmail.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>





    <a href="https://twitter.com/" class="tooltipped" target="_blank" data-tooltip="关注我的Twitter: https://twitter.com/" data-position="top" data-delay="50">
        <i class="fab fa-twitter"></i>
    </a>







    <a href="https://www.zhihu.com/" class="tooltipped" target="_blank" data-tooltip="关注我的知乎: https://www.zhihu.com/" data-position="top" data-delay="50">
        <i class="fab fa-zhihu1">知</i>
    </a>



    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>

    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Global site tag (gtag.js) - Google Analytics -->


    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
